package com.xyzq.reks.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "staff_work")
public class StaffWork extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7012083260699440866L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "FK_STAFF_STAFF", nullable = false)
	private Staff staff;
	@Column(scale = 2)
	private Double deal;
	@Column(scale = 2)
	private Double worth;
	@Column(scale = 2)
	private Double netCommission;
	@Column(scale = 2)
	private Double grade;
	private String month;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;

	public Long getId() {
		return id;
	}

	public Staff getStaff() {
		return staff;
	}

	public Double getDeal() {
		return deal;
	}

	public Double getWorth() {
		return worth;
	}

	public Double getNetCommission() {
		return netCommission;
	}

	public Double getGrade() {
		return grade;
	}

	public String getMonth() {
		return month;
	}

	public Date getSubTime() {
		return subTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	public void setDeal(Double deal) {
		this.deal = deal;
	}

	public void setWorth(Double worth) {
		this.worth = worth;
	}

	public void setNetCommission(Double netCommission) {
		this.netCommission = netCommission;
	}

	public void setGrade(Double grade) {
		this.grade = grade;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((deal == null) ? 0 : deal.hashCode());
		result = prime * result + ((grade == null) ? 0 : grade.hashCode());
		result = prime * result + ((month == null) ? 0 : month.hashCode());
		result = prime * result
				+ ((netCommission == null) ? 0 : netCommission.hashCode());
		result = prime * result + ((staff == null) ? 0 : staff.hashCode());
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		result = prime * result + ((worth == null) ? 0 : worth.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		StaffWork other = (StaffWork) obj;
		if (deal == null) {
			if (other.deal != null)
				return false;
		} else if (!deal.equals(other.deal))
			return false;
		if (grade == null) {
			if (other.grade != null)
				return false;
		} else if (!grade.equals(other.grade))
			return false;
		if (month == null) {
			if (other.month != null)
				return false;
		} else if (!month.equals(other.month))
			return false;
		if (netCommission == null) {
			if (other.netCommission != null)
				return false;
		} else if (!netCommission.equals(other.netCommission))
			return false;
		if (staff == null) {
			if (other.staff != null)
				return false;
		} else if (!staff.equals(other.staff))
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		if (worth == null) {
			if (other.worth != null)
				return false;
		} else if (!worth.equals(other.worth))
			return false;
		return true;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE);
		builder.append("id", id);
		builder.append("staff", staff);
		builder.append("deal", deal);
		builder.append("worth", worth);
		builder.append("netCommission", netCommission);
		builder.append("grade", grade);
		builder.append("month", month);
		builder.append("subTime", subTime);
		return builder.toString();
	}

}
